package com.yjian.service;

import com.yjian.common.CodeMap;
import com.yjian.common.SDataResult;
import com.yjian.dao.bean.Member;
import com.yjian.dao.bean.PayLog;
import com.yjian.dao.mapper.MemberMapper;
import com.yjian.dao.mapper.PayLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by xuxiaobao on 2017/9/29.
 */
@Service
public class PayLogService {
    @Autowired
    private PayLogMapper payLogMapper;
    @Autowired
    private MemberMapper memberMapper;

    public Object getMemberPayLogPart(String uid, String mid) {
        Member member = new Member();
        member.setUid(uid);
        member.setMid(mid);
        int flag = memberMapper.isExistMemberAndUser(member);
        if (flag <= 0) {
            return new SDataResult(CodeMap.FAIL,"会员不存在");
        }

        Map<String, Object> param = new HashMap<>();
        param.put("mid", mid);
        param.put("offSet",0);
        param.put("pageSize",2);
        List<PayLog> list = payLogMapper.getPayLogPageByMid(param);
        if (list == null) {
            return SDataResult.success(new ArrayList<>());
        }
        return SDataResult.success(list);
    }
}
